<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hyperledger Fabric 资产追踪系统</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#165DFF',
                        secondary: '#0FC6C2',
                        success: '#00B42A',
                        warning: '#FF7D00',
                        danger: '#F53F3F',
                        dark: '#1D2129',
                        light: '#F2F3F5'
                    },
                    fontFamily: {
                        inter: ['Inter', 'system-ui', 'sans-serif'],
                    },
                }
            }
        }
    </script>
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .card-shadow {
                box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.1);
            }
            .gradient-bg {
                background: linear-gradient(135deg, #165DFF 0%, #0FC6C2 100%);
            }
            .input-focus {
                @apply focus:ring-2 focus:ring-primary/50 focus:border-primary;
            }
        }
    </style>
</head>
<body class="font-inter bg-gray-50 min-h-screen flex flex-col">
    <!-- 导航栏 -->
    <nav class="bg-white shadow-md fixed w-full z-50 transition-all duration-300" id="navbar">
        <div class="container mx-auto px-4 py-3 flex justify-between items-center">
            <div class="flex items-center space-x-2">
                <i class="fa fa-cubes text-primary text-2xl"></i>
                <h1 class="text-xl font-bold text-dark">资产追踪系统</h1>
            </div>
            <div class="hidden md:flex items-center space-x-6">
                <a href="#create" class="text-gray-700 hover:text-primary transition-colors">资产上链</a>
                <a href="#query" class="text-gray-700 hover:text-primary transition-colors">资产查询</a>
                <a href="#transfer" class="text-gray-700 hover:text-primary transition-colors">资产转移</a>
                <a href="#history" class="text-gray-700 hover:text-primary transition-colors">交易历史</a>
            </div>
            <button class="md:hidden text-gray-700 focus:outline-none" id="menu-toggle">
                <i class="fa fa-bars text-xl"></i>
            </button>
        </div>
        <!-- 移动端菜单 -->
        <div class="md:hidden hidden bg-white w-full border-t" id="mobile-menu">
            <div class="container mx-auto px-4 py-2 flex flex-col space-y-3">
                <a href="#create" class="text-gray-700 hover:text-primary py-2 transition-colors">资产上链</a>
                <a href="#query" class="text-gray-700 hover:text-primary py-2 transition-colors">资产查询</a>
                <a href="#transfer" class="text-gray-700 hover:text-primary py-2 transition-colors">资产转移</a>
                <a href="#history" class="text-gray-700 hover:text-primary py-2 transition-colors">交易历史</a>
            </div>
        </div>
    </nav>

    <!-- 主内容区 -->
    <main class="flex-grow pt-20 pb-10">
        <div class="container mx-auto px-4">
            <!-- 欢迎横幅 -->
            <section class="mb-12 text-center">
                <div class="gradient-bg text-white rounded-2xl p-8 md:p-12 shadow-lg">
                    <h2 class="text-[clamp(1.5rem,3vw,2.5rem)] font-bold mb-4">Hyperledger Fabric 资产追踪平台</h2>
                    <p class="text-lg md:text-xl opacity-90 max-w-3xl mx-auto">
                        通过区块链技术实现资产的透明化、可追溯和安全管理
                    </p>
                    <div class="mt-8 flex flex-wrap justify-center gap-4">
                        <a href="#create" class="bg-white text-primary px-6 py-3 rounded-lg font-medium shadow-md hover:shadow-lg transition-all transform hover:-translate-y-1">
                            <i class="fa fa-plus-circle mr-2"></i>资产上链
                        </a>
                        <a href="#query" class="bg-transparent border-2 border-white text-white px-6 py-3 rounded-lg font-medium hover:bg-white/10 transition-all">
                            <i class="fa fa-search mr-2"></i>查询资产
                        </a>
                    </div>
                </div>
            </section>

            <!-- 功能卡片 -->
            <section class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-12">
                <div class="bg-white rounded-xl p-6 shadow-md hover:shadow-lg transition-all border-l-4 border-primary">
                    <div class="text-primary text-3xl mb-4">
                        <i class="fa fa-chain"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-2">资产上链</h3>
                    <p class="text-gray-600">将各类资产信息安全地记录到区块链上，确保数据不可篡改</p>
                </div>
                <div class="bg-white rounded-xl p-6 shadow-md hover:shadow-lg transition-all border-l-4 border-secondary">
                    <div class="text-secondary text-3xl mb-4">
                        <i class="fa fa-search"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-2">资产查询</h3>
                    <p class="text-gray-600">实时查询链上资产的详细信息和历史记录，确保资产状态透明</p>
                </div>
                <div class="bg-white rounded-xl p-6 shadow-md hover:shadow-lg transition-all border-l-4 border-success">
                    <div class="text-success text-3xl mb-4">
                        <i class="fa fa-exchange"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-2">资产转移</h3>
                    <p class="text-gray-600">安全高效地完成资产所有权转移，自动记录交易历史</p>
                </div>
            </section>

            <!-- 资产上链表单 -->
            <section id="create" class="mb-12 scroll-mt-24">
                <div class="bg-white rounded-xl shadow-lg p-6 md:p-8">
                    <div class="flex items-center mb-6">
                        <div class="bg-primary/10 p-3 rounded-full mr-4">
                            <i class="fa fa-plus-circle text-primary text-xl"></i>
                        </div>
                        <h2 class="text-2xl font-bold text-dark">资产上链</h2>
                    </div>
                    <form id="create-asset-form" class="space-y-6">
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                            <div>
                                <label for="create-id" class="block text-sm font-medium text-gray-700 mb-1">资产ID</label>
                                <input type="text" id="create-id" class="w-full px-4 py-2 border border-gray-300 rounded-lg input-focus transition-all" placeholder="请输入资产ID" required>
                            </div>
                            <div>
                                <label for="create-owner" class="block text-sm font-medium text-gray-700 mb-1">资产所有者</label>
                                <input type="text" id="create-owner" class="w-full px-4 py-2 border border-gray-300 rounded-lg input-focus transition-all" placeholder="请输入所有者" required>
                            </div>
                            <div>
                                <label for="create-name" class="block text-sm font-medium text-gray-700 mb-1">资产名称</label>
                                <input type="text" id="create-name" class="w-full px-4 py-2 border border-gray-300 rounded-lg input-focus transition-all" placeholder="请输入资产名称" required>
                            </div>
                            <div>
                                <label for="create-info" class="block text-sm font-medium text-gray-700 mb-1">资产描述</label>
                                <input type="text" id="create-info" class="w-full px-4 py-2 border border-gray-300 rounded-lg input-focus transition-all" placeholder="请输入资产描述">
                            </div>
                        </div>
                        <div class="flex justify-end">
                            <button type="submit" class="bg-primary hover:bg-primary/90 text-white px-6 py-3 rounded-lg font-medium shadow-md transition-all flex items-center">
                                <i class="fa fa-paper-plane mr-2"></i> 提交上链
                            </button>
                        </div>
                    </form>
                    <div id="create-result" class="mt-6 hidden">
                        <div class="p-4 rounded-lg" id="create-result-message">
                            <!-- 结果信息将在这里显示 -->
                        </div>
                    </div>
                </div>
            </section>

            <!-- 资产查询表单 -->
            <section id="query" class="mb-12 scroll-mt-24">
                <div class="bg-white rounded-xl shadow-lg p-6 md:p-8">
                    <div class="flex items-center mb-6">
                        <div class="bg-secondary/10 p-3 rounded-full mr-4">
                            <i class="fa fa-search text-secondary text-xl"></i>
                        </div>
                        <h2 class="text-2xl font-bold text-dark">资产查询</h2>
                    </div>
                    <div class="flex flex-col md:flex-row gap-4 mb-6">
                        <input type="text" id="query-id" class="flex-grow px-4 py-2 border border-gray-300 rounded-lg input-focus transition-all" placeholder="请输入要查询的资产ID" required>
                        <button id="query-button" class="bg-secondary hover:bg-secondary/90 text-white px-6 py-2 rounded-lg font-medium shadow-md transition-all flex items-center justify-center">
                            <i class="fa fa-search mr-2"></i> 查询
                        </button>
                    </div>
                    <div id="query-result" class="mt-6 hidden">
                        <div class="p-4 bg-gray-50 rounded-lg mb-4">
                            <h3 class="text-lg font-semibold mb-3">资产详情</h3>
                            <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                                <div>
                                    <p class="text-sm text-gray-500">资产ID</p>
                                    <p id="query-result-id" class="font-medium"></p>
                                </div>
                                <div>
                                    <p class="text-sm text-gray-500">所有者</p>
                                    <p id="query-result-owner" class="font-medium"></p>
                                </div>
                                <div>
                                    <p class="text-sm text-gray-500">资产名称</p>
                                    <p id="query-result-name" class="font-medium"></p>
                                </div>
                                <div>
                                    <p class="text-sm text-gray-500">资产描述</p>
                                    <p id="query-result-info" class="font-medium"></p>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div id="query-error" class="mt-6 hidden">
                        <div class="p-4 bg-red-50 text-red-700 rounded-lg">
                            <i class="fa fa-exclamation-circle mr-2"></i>
                            <span id="query-error-message"></span>
                        </div>
                    </div>
                </div>
            </section>

            <!-- 资产转移表单 -->
            <section id="transfer" class="mb-12 scroll-mt-24">
                <div class="bg-white rounded-xl shadow-lg p-6 md:p-8">
                    <div class="flex items-center mb-6">
                        <div class="bg-success/10 p-3 rounded-full mr-4">
                            <i class="fa fa-exchange text-success text-xl"></i>
                        </div>
                        <h2 class="text-2xl font-bold text-dark">资产转移</h2>
                    </div>
                    <form id="transfer-form" class="space-y-6">
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                            <div>
                                <label for="transfer-id" class="block text-sm font-medium text-gray-700 mb-1">资产ID</label>
                                <input type="text" id="transfer-id" class="w-full px-4 py-2 border border-gray-300 rounded-lg input-focus transition-all" placeholder="请输入要转移的资产ID" required>
                            </div>
                            <div>
                                <label for="transfer-owner" class="block text-sm font-medium text-gray-700 mb-1">新所有者</label>
                                <input type="text" id="transfer-owner" class="w-full px-4 py-2 border border-gray-300 rounded-lg input-focus transition-all" placeholder="请输入新所有者" required>
                            </div>
                        </div>
                        <div class="flex justify-end">
                            <button type="submit" class="bg-success hover:bg-success/90 text-white px-6 py-3 rounded-lg font-medium shadow-md transition-all flex items-center">
                                <i class="fa fa-paper-plane mr-2"></i> 提交转移
                            </button>
                        </div>
                    </form>
                    <div id="transfer-result" class="mt-6 hidden">
                        <div class="p-4 rounded-lg" id="transfer-result-message">
                            <!-- 结果信息将在这里显示 -->
                        </div>
                    </div>
                </div>
            </section>

            <!-- 交易历史 -->
            <section id="history" class="scroll-mt-24">
                <div class="bg-white rounded-xl shadow-lg p-6 md:p-8">
                    <div class="flex items-center mb-6">
                        <div class="bg-warning/10 p-3 rounded-full mr-4">
                            <i class="fa fa-history text-warning text-xl"></i>
                        </div>
                        <h2 class="text-2xl font-bold text-dark">交易历史</h2>
                    </div>
                    <div class="overflow-x-auto">
                        <table class="min-w-full divide-y divide-gray-200">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">交易ID</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">资产ID</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">操作类型</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">操作时间</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">详细信息</th>
                                </tr>
                            </thead>
                            <tbody class="bg-white divide-y divide-gray-200" id="history-table-body">
                                <!-- 交易历史记录将在这里动态添加 -->
                                <tr class="text-center">
                                    <td colspan="5" class="px-6 py-12 text-gray-500">
                                        <i class="fa fa-clock-o text-2xl mb-2"></i>
                                        <p>暂无交易记录</p>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="mt-4 flex justify-center">
                        <button id="load-more-history" class="text-primary hover:text-primary/80 font-medium flex items-center">
                            <i class="fa fa-refresh mr-2"></i> 加载更多
                        </button>
                    </div>
                </div>
            </section>
        </div>
    </main>

    <!-- 页脚 -->
    <footer class="bg-dark text-white py-10">
        <div class="container mx-auto px-4">
            <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
                <div>
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fa fa-cubes mr-2"></i> 资产追踪系统
                    </h3>
                    <p class="text-gray-400">基于 Hyperledger Fabric 区块链技术构建的资产追踪平台，提供安全、透明、可追溯的资产全生命周期管理。</p>
                </div>
                <div>
                    <h3 class="text-lg font-semibold mb-4">快速链接</h3>
                    <ul class="space-y-2">
                        <li><a href="#create" class="text-gray-400 hover:text-white transition-colors">资产上链</a></li>
                        <li><a href="#query" class="text-gray-400 hover:text-white transition-colors">资产查询</a></li>
                        <li><a href="#transfer" class="text-gray-400 hover:text-white transition-colors">资产转移</a></li>
                        <li><a href="#history" class="text-gray-400 hover:text-white transition-colors">交易历史</a></li>
                    </ul>
                </div>
                <div>
                    <h3 class="text-lg font-semibold mb-4">联系我们</h3>
                    <ul class="space-y-2">
                        <li class="flex items-center">
                            <i class="fa fa-envelope-o mr-2 text-gray-400"></i>
                            <a href="mailto:contact@example.com" class="text-gray-400 hover:text-white transition-colors">contact@example.com</a>
                        </li>
                        <li class="flex items-center">
                            <i class="fa fa-phone mr-2 text-gray-400"></i>
                            <span class="text-gray-400">+86 123 4567 8901</span>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-500">
                <p>© 2025 资产追踪系统. 保留所有权利.</p>
            </div>
        </div>
    </footer>

    <script>
        // 导航栏滚动效果
        const navbar = document.getElementById('navbar');
        window.addEventListener('scroll', () => {
            if (window.scrollY > 10) {
                navbar.classList.add('py-2', 'shadow-lg');
                navbar.classList.remove('py-3', 'shadow-md');
            } else {
                navbar.classList.add('py-3', 'shadow-md');
                navbar.classList.remove('py-2', 'shadow-lg');
            }
        });

        // 移动端菜单切换
        const menuToggle = document.getElementById('menu-toggle');
        const mobileMenu = document.getElementById('mobile-menu');
        menuToggle.addEventListener('click', () => {
            mobileMenu.classList.toggle('hidden');
        });

        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function(e) {
                e.preventDefault();
                const targetId = this.getAttribute('href');
                const targetElement = document.querySelector(targetId);
                if (targetElement) {
                    window.scrollTo({
                        top: targetElement.offsetTop - 80,
                        behavior: 'smooth'
                    });
                    // 关闭移动菜单（如果打开）
                    if (!mobileMenu.classList.contains('hidden')) {
                        mobileMenu.classList.add('hidden');
                    }
                }
            });
        });

        // 模拟API调用 - 实际使用时需要替换为真实的后端API
        function simulateApiCall(data, successRate = 0.9) {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    if (Math.random() < successRate) {
                        resolve({
                            success: true,
                            data: data,
                            txId: 'TX' + Math.floor(Math.random() * 1000000000).toString().padStart(9, '0'),
                            timestamp: new Date().toISOString()
                        });
                    } else {
                        reject({
                            success: false,
                            message: '模拟API调用失败，请重试'
                        });
                    }
                }, 1000);
            });
        }

        // 资产上链表单提交
        document.getElementById('create-asset-form').addEventListener('submit', async function(e) {
            e.preventDefault();
            const form = e.target;
            const resultDiv = document.getElementById('create-result');
            const resultMessage = document.getElementById('create-result-message');
            
            try {
                // 显示加载状态
                resultDiv.classList.remove('hidden');
                resultMessage.className = 'p-4 bg-blue-50 text-blue-700 rounded-lg';
                resultMessage.innerHTML = '<i class="fa fa-spinner fa-spin mr-2"></i> 正在处理上链请求...';
                
                // 收集表单数据
                const formData = {
                    id: form.querySelector('#create-id').value,
                    owner: form.querySelector('#create-owner').value,
                    name: form.querySelector('#create-name').value,
                    info: form.querySelector('#create-info').value
                };
                
                // 模拟API调用
                const response = await simulateApiCall({
                    message: '资产上链成功',
                    asset: formData
                });
                
                // 显示成功结果
                resultMessage.className = 'p-4 bg-green-50 text-green-700 rounded-lg';
                resultMessage.innerHTML = `
                    <i class="fa fa-check-circle mr-2"></i>
                    <div>
                        <p>资产上链成功！</p>
                        <p class="mt-2 text-sm">交易ID: <span class="font-medium">${response.txId}</span></p>
                        <p class="text-sm">时间戳: <span class="font-medium">${new Date(response.timestamp).toLocaleString()}</span></p>
                    </div>
                `;
                
                // 添加到交易历史
                addToHistory({
                    txId: response.txId,
                    assetId: formData.id,
                    type: '创建',
                    timestamp: response.timestamp,
                    details: `创建资产: ${formData.name}`
                });
                
                // 清空表单
                form.reset();
            } catch (error) {
                // 显示错误结果
                resultMessage.className = 'p-4 bg-red-50 text-red-700 rounded-lg';
                resultMessage.innerHTML = `<i class="fa fa-exclamation-circle mr-2"></i> ${error.message || '资产上链失败，请重试'}`;
            }
        });

        // 资产查询
        document.getElementById('query-button').addEventListener('click', async function() {
            const queryId = document.getElementById('query-id').value;
            const resultDiv = document.getElementById('query-result');
            const errorDiv = document.getElementById('query-error');
            const errorMessage = document.getElementById('query-error-message');
            
            if (!queryId) {
                errorDiv.classList.remove('hidden');
                errorMessage.textContent = '请输入要查询的资产ID';
                resultDiv.classList.add('hidden');
                return;
            }
            
            try {
                // 显示加载状态
                errorDiv.classList.add('hidden');
                resultDiv.classList.remove('hidden');
                
                // 清空结果
                document.getElementById('query-result-id').textContent = '加载中...';
                document.getElementById('query-result-owner').textContent = '加载中...';
                document.getElementById('query-result-name').textContent = '加载中...';
                document.getElementById('query-result-info').textContent = '加载中...';
                
                // 模拟API调用
                const response = await simulateApiCall({
                    id: queryId,
                    owner: '所有者' + Math.floor(Math.random() * 100),
                    name: '资产名称' + Math.floor(Math.random() * 100),
                    info: '这是一个测试资产，创建于 ' + new Date().toLocaleDateString()
                });
                
                // 填充结果
                document.getElementById('query-result-id').textContent = response.data.id;
                document.getElementById('query-result-owner').textContent = response.data.owner;
                document.getElementById('query-result-name').textContent = response.data.name;
                document.getElementById('query-result-info').textContent = response.data.info;
                
                // 添加到交易历史
                addToHistory({
                    txId: 'VIEW' + Math.floor(Math.random() * 1000000000).toString().padStart(9, '0'),
                    assetId: queryId,
                    type: '查询',
                    timestamp: new Date().toISOString(),
                    details: '查看资产详情'
                });
            } catch (error) {
                // 显示错误
                resultDiv.classList.add('hidden');
                errorDiv.classList.remove('hidden');
                errorMessage.textContent = error.message || '查询失败，请重试';
            }
        });

        // 资产转移表单提交
        document.getElementById('transfer-form').addEventListener('submit', async function(e) {
            e.preventDefault();
            const form = e.target;
            const resultDiv = document.getElementById('transfer-result');
            const resultMessage = document.getElementById('transfer-result-message');
            
            try {
                // 显示加载状态
                resultDiv.classList.remove('hidden');
                resultMessage.className = 'p-4 bg-blue-50 text-blue-700 rounded-lg';
                resultMessage.innerHTML = '<i class="fa fa-spinner fa-spin mr-2"></i> 正在处理转移请求...';
                
                // 收集表单数据
                const formData = {
                    id: form.querySelector('#transfer-id').value,
                    owner: form.querySelector('#transfer-owner').value
                };
                
                // 模拟API调用
                const response = await simulateApiCall({
                    message: '资产转移成功',
                    assetId: formData.id,
                    newOwner: formData.owner
                });
                
                // 显示成功结果
                resultMessage.className = 'p-4 bg-green-50 text-green-700 rounded-lg';
                resultMessage.innerHTML = `
                    <i class="fa fa-check-circle mr-2"></i>
                    <div>
                        <p>资产转移成功！</p>
                        <p class="mt-2 text-sm">资产ID: <span class="font-medium">${formData.id}</span></p>
                        <p class="text-sm">新所有者: <span class="font-medium">${formData.owner}</span></p>
                        <p class="text-sm">交易ID: <span class="font-medium">${response.txId}</span></p>
                        <p class="text-sm">时间戳: <span class="font-medium">${new Date(response.timestamp).toLocaleString()}</span></p>
                    </div>
                `;
                
                // 添加到交易历史
                addToHistory({
                    txId: response.txId,
                    assetId: formData.id,
                    type: '转移',
                    timestamp: response.timestamp,
                    details: `转移给 ${formData.owner}`
                });
                
                // 清空表单
                form.reset();
            } catch (error) {
                // 显示错误结果
                resultMessage.className = 'p-4 bg-red-50 text-red-700 rounded-lg';
                resultMessage.innerHTML = `<i class="fa fa-exclamation-circle mr-2"></i> ${error.message || '资产转移失败，请重试'}`;
            }
        });

        // 添加交易历史记录
        function addToHistory(record) {
            const historyTableBody = document.getElementById('history-table-body');
            
            // 移除"暂无交易记录"行
            if (historyTableBody.querySelector('td[colspan="5"]')) {
                historyTableBody.innerHTML = '';
            }
            
            // 创建新行
            const row = document.createElement('tr');
            row.className = 'hover:bg-gray-50 transition-colors';
            
            // 格式化时间
            const formattedTime = new Date(record.timestamp).toLocaleString();
            
            // 设置行内容
            row.innerHTML = `
                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">${record.txId}</td>
                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">${record.assetId}</td>
                <td class="px-6 py-4 whitespace-nowrap">
                    <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${
                        record.type === '创建' ? 'bg-blue-100 text-blue-800' : 
                        record.type === '转移' ? 'bg-green-100 text-green-800' : 
                        'bg-gray-100 text-gray-800'
                    }">${record.type}</span>
                </td>
                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${formattedTime}</td>
                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${record.details}</td>
            `;
            
            // 添加到表格顶部
            historyTableBody.insertBefore(row, historyTableBody.firstChild);
        }

        // 加载更多历史记录
        document.getElementById('load-more-history').addEventListener('click', async function() {
            try {
                // 显示加载状态
                this.innerHTML = '<i class="fa fa-spinner fa-spin mr-2"></i> 加载中...';
                
                // 模拟API调用获取更多历史记录
                const responses = await Promise.all([
                    simulateApiCall({
                        txId: 'TX' + Math.floor(Math.random() * 1000000000).toString().padStart(9, '0'),
                        assetId: 'ASSET' + Math.floor(Math.random() * 1000),
                        type: '创建',
                        timestamp: new Date(Date.now() - Math.floor(Math.random() * 86400000)).toISOString(),
                        details: '创建资产: 测试资产' + Math.floor(Math.random() * 100)
                    }),
                    simulateApiCall({
                        txId: 'TX' + Math.floor(Math.random() * 1000000000).toString().padStart(9, '0'),
                        assetId: 'ASSET' + Math.floor(Math.random() * 1000),
                        type: '转移',
                        timestamp: new Date(Date.now() - Math.floor(Math.random() * 86400000)).toISOString(),
                        details: '转移给: 用户' + Math.floor(Math.random() * 100)
                    })
                ]);
                
                // 添加到历史记录
                responses.forEach(res => {
                    addToHistory({
                        txId: res.txId,
                        assetId: res.data.assetId,
                        type: res.data.type,
                        timestamp: res.data.timestamp,
                        details: res.data.details
                    });
                });
                
                // 恢复按钮状态
                this.innerHTML = '<i class="fa fa-refresh mr-2"></i> 加载更多';
            } catch (error) {
                alert('加载历史记录失败: ' + error.message);
                this.innerHTML = '<i class="fa fa-refresh mr-2"></i> 加载更多';
            }
        });
    </script>
</body>
</html>
    